home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Strings / Numeral.h < prev    next >
Text File  |  1997-06-28  |  1KB  |  59 lines

  1. // Numeral.h
  2.  
  3. #ifndef Numeral_h
  4. #define Numeral_h
  5.  
  6. #ifndef Integers_h
  7. #include "Integers.h"
  8. #endif
  9.  
  10. class Numeral
  11.   {
  12.     private:
  13.         enum
  14.           {
  15.             minus = '-',
  16.             plus = '+',
  17.             none = ' '
  18.           };
  19.         
  20.         uint8 *firstDigit;
  21.         uint8 sign;
  22.         bool showSign;
  23.         
  24.         enum { maxLength = 66 };
  25.         uint8 digits[ maxLength ];
  26.     
  27.         void MakeDigits( uint32 value, uint32 base );
  28.         uint8 Digit( uint32 n );
  29.         
  30.         uint8 Sign( uint32 value );
  31.         uint8 Sign( int32 value );
  32.  
  33.         void MakeDigits64( uint64 value, uint32 base );
  34.         uint8 Sign( uint64 value );
  35.         uint8 Sign( int64 value );
  36.         
  37.     public:
  38.         Numeral( uint64, uint32 base = 10 );
  39.         Numeral( int64, uint32 base = 10 );
  40.  
  41.         Numeral( uint32, uint32 base = 10 );
  42.         Numeral( int32, uint32 base = 10 );
  43.  
  44.         Numeral( uint16, uint32 base = 10 );
  45.         Numeral( int16, uint32 base = 10 );
  46.  
  47.         Numeral( uint8, uint32 base = 10 );
  48.         Numeral( int8, uint32 base = 10 );
  49.         
  50.         void PadTo( uint32 digits );
  51.         void ShowSign()                { showSign = true; }
  52.         
  53.         uint32 DigitCount() const    { return digits + maxLength - firstDigit; }
  54.         
  55.         operator ConstStr255Param() const;
  56.   };
  57.  
  58. #endif
  59.